//引入样式
require("../../assets/css/reset.css")
require('../../assets/css/normalize.css')
require('../../assets/fonts/iconfont.css')

require('./sports_course_detail.less');

//引入模块
const dom = require('../../utils/dom.js');
const axios = require('../../utils/axios.js');

document.addEventListener('DOMContentLoaded', function () {
    let id = location.search.split('=').pop();
    // 渲染页面
    axios.get('/api/train/courseDetail?id=' + `${id}`).then(res => {
        let courseData = res.data.data
        console.log(courseData);
        dom.get('#video').src = axios.defaults.baseURL + courseData.fragments[id].videoUrl;
        dom.get('#text').textContent = courseData.desc.slice(0, 18) + '...';
        dom.get('.content h4').textContent = courseData.name;
        dom.get('#time').textContent = courseData.time;
        dom.get('#calorie').textContent = courseData.calorie;

        let fragments = res.data.data.fragments;
        localStorage.setItem('courseData', JSON.stringify(fragments));
    })
    // 点击返回上一页
    dom.get('.icon-zuojiantou1').addEventListener("click", function () {
        history.back();
    })

})